#ifndef __win32_io_stream__h__included__
#define __win32_io_stream__h__included__
          
#include <windows.h>

#include <string>

#include "neiderra/core/Base.h"
#include "neiderra/core/io/IOStream.h"

using namespace neiderra::core;

namespace neiderra 
{ 
	namespace core 
	{ 

		//! win32 Output Stream implementation
		class win32OutputStream: public iOutputStream 
		{
		public:
			win32OutputStream(Core* );

			virtual ~win32OutputStream();

			virtual bool open(const char* filename);

			virtual void close();

			int write(const char* buf, int n);

			int write(const char* buf);

			int writeln(const char* buf);

			int writeln(const std::string& s)
			{
				return writeln(s.c_str());
			}

			const char* sourceName() { return filename_.c_str(); }
		private:
			HANDLE file_;
			std::string filename_;
		};

		// win32 input stream implementation
		class win32InputStream: public iInputStream
		{
		public:
			win32InputStream(Core* core_);

			virtual ~win32InputStream();

			virtual bool open(const char* filename);

			virtual void close();

			int read(char* buf, int n);

			int size() ;

			virtual bool reopen()
			{
				close();
				return open(filename_.c_str());
			}

			virtual long pos();

			virtual int seek(long n, SeekType type);

			const char* sourceName() { return filename_.c_str(); }
		private:
			HANDLE file_;
			std::string filename_;
			bool _opened;
		};

	}
}

#endif 
